<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/css/ceb/gift-packs.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">


    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>奖池管理 <small>编辑</small></h5>
                </div>
                <div class="ibox-content">
                    <form method="post" action="/admin/permission/doCreate" class="form-horizontal">
                        {{csrf_field()}}
                        <input type="hidden" name="info[cid]" value=""/>
                        <div class="form-group  ">
                            <label class="col-sm-2 control-label">奖池名称：</label>
                            <div class="col-sm-6">
                                <div class="row">
                                    <div class="col-md-8">
                                        <input type="text" name="info[name]" value="{{ old('info')['name'] }}"
                                               placeholder="奖池名称" class="form-control">
                                        <span class="help-block m-b-none">{{$errors->first('info.name')}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group @if($errors->has('info.description')) has-error @endif">
                            <label class="col-sm-2 control-label">有效时间：</label>
                            <div class="col-sm-2 m-b-xs">
                                <div class="input-group">
                                    <input placeholder="开始日期" class="form-control layer-date" readonly id="start">
                                </div>
                            </div>
                            <div class="col-sm-2 m-b-xs">
                                <div class="input-group">
                                    <input placeholder="结束日期" readonly  class="form-control layer-date" id="end">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-6 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" id="add-xj" data-toggle="modal" data-target="#myModal-xj">添加现金券</button>
                                <button class="btn btn-danger" type="button" id="add-hb" data-toggle="modal" data-target="#myModal-hb">添加红包</button>
                                <button class="btn btn-warning" type="button" id="add-jx" data-toggle="modal" data-target="#myModal-jx">添加加息券</button>

                                {{--现金券开始--}}
                                <div class="modal inmodal " id="myModal-xj" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog ">
                                        <div class="modal-content animated bounceInRight">

                                            <div class="col-sm-12 _block-xj _block-quan">
                                                <div class="contact-box border-xj">
                                                    <div class="col-sm-12">
                                                        <h3 ><strong>现金券</strong></h3>
                                                        <div class="form-group">
                                                            <label class="col-sm-4 control-label">名称：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-xj-name" value=""
                                                                               placeholder="名称" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">面值：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-xj-val" value=""
                                                                               placeholder="面值" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group  ">
                                                            <div class="col-sm-12">
                                                            <h5 class="">使用条件<small></small></h5>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">起投金额：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-xj-atleast" value=""
                                                                               placeholder="起投金额" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">期限(天)：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id = "input-xj-atleastDay" value=""
                                                                               placeholder="期限" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">有效期：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <div class="radio i-checks">
                                                                            <label>
                                                                                <input type="radio" checked="false" value="2" name="xjq[limitype]"> <i></i> 有效天数</label>
                                                                        </div>
                                                                        <div class="radio i-checks">
                                                                            <label>
                                                                                <input type="radio" checked="false" value="1" name="xjq[limitype]"> <i></i> 截止日期</label>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">领取后有效天数(天)：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" name=""  value=""
                                                                               placeholder="领取后有效天数(天)" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group  ">
                                                            <label class="col-sm-4 control-label">截止日期：</label>
                                                            <div class="col-sm-8">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input placeholder="截止日期" readonly name="xjq[NUMBER][effectiveDate]" class="form-control layer-date" id="xjq-date-NUMBER">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-white _remove-one-ticket" type="button" data-dismiss="modal">取消</button>
                                                            </div>
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-primary"  type="button">确定</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                {{--END 现金券--}}

                                {{--加息券开始--}}
                                <div class="modal inmodal " id="myModal-jx" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog ">
                                        <div class="modal-content animated bounceInRight">

                                            <div class="col-sm-12 _block-jx _block-quan">
                                                <div class="contact-box border-jx">
                                                    <div class="col-sm-12">
                                                        <h3><strong>加息券</strong></h3>
                                                        <div class="form-group">
                                                            <label class="col-sm-5 control-label">名称：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-jx-name" value=""
                                                                               placeholder="名称" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">加息值(%)：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-jx-val" value=""
                                                                               placeholder="加息值" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>


                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">起投金额：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-jx-atleast" value=""
                                                                               placeholder="起投金额" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">期限(天)：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" id="input-jx-atleastDay" value=""
                                                                               placeholder="期限" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">有效期：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <div class="radio i-checks">
                                                                            <label>
                                                                                <input type="radio" checked value ="input-jx-effectiveday" name="limitType"> <i></i> 有效天数</label>
                                                                        </div>
                                                                        <div class="radio i-checks">
                                                                            <label>
                                                                                <input type="radio"  value="input-jx-effectivedate" name="limitType"> <i></i> 截止日期</label>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="_eftive-container">
                                                            <div class="form-group" style="display: block">
                                                                <label class="col-sm-5 control-label">领取后有效天数(天)：</label>
                                                                <div class="col-sm-7">
                                                                    <div class="row">
                                                                        <div class="col-md-12">
                                                                            <input type="text" id="input-jx-effectiveday" value=""
                                                                                   placeholder="领取后有效天数(天)" class="form-control">
                                                                            <span class="help-block m-b-none"></span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>

                                                            <div class="form-group" style="display: none">
                                                                <label class="col-sm-5 control-label">截止日期：</label>
                                                                <div class="col-sm-7">
                                                                    <div class="row">
                                                                        <div class="col-md-12">
                                                                            <input placeholder="截止日期" readonly class="form-control layer-date" id="input-jx-effectivedate">
                                                                            <span class="help-block m-b-none"></span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-white"  type="button" data-dismiss="modal">取消</button>
                                                            </div>
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-primary" id="btn-add-jx" type="button">确定</button>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="clearfix"></div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                {{--END加息券--}}

                                {{--加息券开始--}}
                                <div class="modal inmodal " id="myModal-hb" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog ">
                                        <div class="modal-content animated bounceInRight">

                                            <div class="col-sm-12 _block-hb _block-quan">
                                                <div class="contact-box border-hb">
                                                    <div class="col-sm-12">
                                                        <h3 ><strong>红包</strong></h3>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">名称：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" name="hb[NUMBER][name]" value=""
                                                                               placeholder="名称" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group  ">
                                                            <label class="col-sm-5 control-label">面值：</label>
                                                            <div class="col-sm-7">
                                                                <div class="row">
                                                                    <div class="col-md-12">
                                                                        <input type="text" name="info[NUMBER][val]" value=""
                                                                               placeholder="面值" class="form-control">
                                                                        <span class="help-block m-b-none"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-white" type="button" data-dismiss="modal">取消</button>
                                                            </div>
                                                            <div class="col-sm-4 col-sm-offset-2">
                                                                <button class="btn btn-primary " type="button">确定</button>
                                                            </div>

                                                        </div>

                                                    </div>
                                                    <div class="clearfix"></div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                {{--END加息券结束--}}


                            </div>
                        </div>

                        <div class="ibox-title">
                            <h5>奖池<small></small></h5>
                        </div>
                        <div class="row">
                            <div class="gift-packs-container">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th> </th>
                                        <th>券名称</th>
                                        <th>面值</th>
                                        <th>起投金额</th>
                                        <th>期限</th>
                                        <th>有效期</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="_table-quan-container">
                                    <tr class="gradeA">
                                        <td>现金券</td>
                                        <td><input  class="form-control" readonly id="start"></td>
                                        <td><input  class="form-control" readonly id="start"></td>
                                        <td><input  class="form-control" readonly id="start"></td>
                                        <td><input  class="form-control" readonly id="start"></td>
                                        <td><input  class="form-control" readonly id="start"></td>
                                        <td class="center">
                                            <a href="javascript:void(0);" class="delete-remove">删除</a>
                                        </td>
                                    </tr>

                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <th> </th>
                                        <th>券名称</th>
                                        <th>面值</th>
                                        <th>起投金额</th>
                                        <th>期限</th>
                                        <th>有效期</th>
                                        <th>操作</th>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <a href="javascript:void(0);" onclick="window.history.back()">
                                    <button class="btn btn-white" type="button">取消</button>
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>

<script src="/js/plugins/layer/layer.min.js"></script>

<!-- iCheck -->
<script src="/js/plugins/iCheck/icheck.min.js"></script>
<!-- layerDate plugin javascript -->
<script src="/js/plugins/layer/laydate/laydate.js"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0"></script>


<script>
    $(document).ready(function(){
        var ex_int = /^\d+$/;
        var count_tr = $('._table-quan-container').children('tr').length

        //添加红包
        $("#btn-add-hb").click(function () {

        });
        //添加加息券
        $("#btn-add-jx").click(function () {

            var jxq={};
            if($('#input-jx-name').val().length==0){
                $('#input-jx-name').next().html('券名不能为空');
                $('#input-jx-name').parents('.form-group').addClass('has-error');
                return false;
            }
            $('#input-jx-name').next().html('');
            $('#input-jx-name').parents('.form-group').removeClass('has-error');

            if($("#input-jx-val").val().length==0){
                $('#input-jx-val').next().html('加息值不能为空');
                $('#input-jx-val').parents('.form-group').addClass('has-error');
                return false;
            }
            if(isNaN($("#input-jx-val").val())){
                $('#input-jx-val').next().html('加息值必须为数字');
                $('#input-jx-val').parents('.form-group').addClass('has-error');
                return false;
            }
            $('#input-jx-val').next().html('');
            $('#input-jx-val').parents('.form-group').removeClass('has-error');

            if($("#input-jx-atleast").val().length>0 && !ex_int.test($("#input-jx-atleast").val())){
                $('#input-jx-atleast').next().html('起投金额必须为整数');
                $('#input-jx-atleast').parents('.form-group').addClass('has-error');
                return false;
            }
            $('#input-jx-atleast').next().html('');
            $('#input-jx-atleast').parents('.form-group').removeClass('has-error');

            if($("#input-jx-atleastDay").val().length>0 && !ex_int.test($("#input-jx-atleastDay").val())){
                $('#input-jx-atleastDay').next().html('期限必须为整数');
                $('#input-jx-atleastDay').parents('.form-group').addClass('has-error');
                return false;
            }
            $('#input-jx-atleastDay').next().html('');
            $('#input-jx-atleastDay').parents('.form-group').removeClass('has-error');

            var effectiveId = $("input[name='limitType']").val();
            if(effectiveId =='input-jx-effectiveday' && $("#"+effectiveId).val().length>0 ){
                if(!ex_int.test($("#"+effectiveId).val())){
                    $("#"+effectiveId).next().html('有效天数必须为整数');
                    $("#"+effectiveId).parents('.form-group').addClass('has-error');
                    return false;
                }
            }
            $("#"+effectiveId).next().html('');
            $("#"+effectiveId).parents('.form-group').removeClass('has-error');

            var _url= '/js/admin/ceb/gift-packs-tr-template.html?v=322';
            $.get( _url).success(function(data){
                var _strhtml=data;
                var reg_type=/TYPE/g;
                _strhtml=_strhtml.replace(reg_type,'JXQ');
                var reg_type=/NUMBER/g;
                _strhtml=_strhtml.replace(reg_type,count_tr);
                var reg_type=/TITLE/g;
                _strhtml=_strhtml.replace(reg_type,'加息券');
                $("._table-quan-container").prepend(_strhtml);

               [1][name];
                $("input[name=JXQ"   "]").val();

                count_tr++;
                //移除事件
                $(".delete-remove").click(function () {
                    $(this).parents('tr').remove();
                });
            });

        });

        //添加现金券
        $("#btn-add-xj").click(function () {
        });

        //加息chebox 点击
        $("input[name='limitType']").change(function () {
            var docment = $("#"+$(this).val()).parents('.form-group');
            docment.show().siblings().hide();
        });

        //移除事件
        $(".delete-remove").click(function () {
            $(this).parents('tr').remove();
        });
        
    });
</script>

</body>

</html>
